package com.example.keymanagertwo.KeyDao;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;


import com.example.keymanagertwo.Bean.Bean;
import com.example.keymanagertwo.entity.Sqlhelper;

import java.util.ArrayList;
import java.util.List;

public class KeyDao {

    private final Sqlhelper sqlhelper;

    public KeyDao(Context context) {


        sqlhelper = new Sqlhelper(context);
    }

public List<Bean> getall(){
        List<Bean> list=new ArrayList<>();
    SQLiteDatabase db=sqlhelper.getReadableDatabase();
    String sql_insert="select * from keys";
    Cursor cs = db.rawQuery(sql_insert, null);
    while(cs.moveToNext()){
        Bean ba=new Bean();
        ba.set_id(cs.getInt(0));
        ba.setAddress(cs.getString(1));
        ba.setRomm(cs.getString(2));
        ba.setData(cs.getString(3));

        list.add(ba);



    }
    cs.close();

    return list;


}


}
